package com.item.news.test;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName info
 * @Description TODO
 * @Author WangDong
 * @Date 2019/1/18 11:46
 * @Version 1.0
 **/
public class info {
    public static void main(String[] args) {
        String url = "http://news.qingdaonews.com/qingdao/2019-01/18/content_20275582.htm";
       // String url = "http://news.qingdaonews.com/zonghe/";
        try {
            Document doc = Jsoup.connect(url).get();
            Elements body = doc.select(" div[class=\"g-box-7\"] "); //带有href属性的a元素
            Elements title = doc.select(" h1[class=\"m-tt-1\"] "); //带有href属性的a元素
            Elements newsinfo = doc.select(" div[class=\"g-box-2 mb30\"]>div[class=\"m-msg-1\"]>span"); //带有href属性的a元素
            Elements content = doc.select(" div[class=\"g-box-3 fl\"]>div[ class=\"m-ct mb80\"]>p"); //带有href属性的a元素
            /*System.out.println("这是数据："+body);
            System.out.println("这是标题："+title);
            System.out.println("这是小信息："+newsinfo);*/
            System.out.println("内容："+content.html());

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
